package com.gugu.procedure.controller;


import com.gugu.procedure.bean.Role;
import com.gugu.procedure.common.HttpServletRequestUtils;
import com.gugu.procedure.common.MessageResult;
import com.gugu.procedure.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = {"角色模块"})
@RequestMapping("role")
public class RoleController {

    @Autowired
    private RoleService roleService;
    @Autowired
    private HttpServletRequestUtils httpServletRequestUtils;

    @PostMapping("add")
    @ApiOperation(value = "新增")
    public MessageResult add(@RequestBody Role role) {
        return roleService.add(role);
    }

    @PostMapping("update")
    @ApiOperation(value = "更新")
    public MessageResult update(@RequestBody Role role) {
        return roleService.update(role);
    }

    @GetMapping("page")
    @ApiOperation(value = "分页查询")
    public MessageResult page(String name, int pageNo, int pageSize) {
        return roleService.page(name, pageNo, pageSize);
    }

    @GetMapping("delete")
    @ApiOperation(value = "删除")
    public MessageResult delete(Long id) {
        return roleService.delete(id);
    }

    @GetMapping("list")
    @ApiOperation(value = "列表")
    public MessageResult list() {
        return roleService.listAll();
    }


}
